<?php

/**
 * Default validator, only checks for required fields
 *
 */
class Validator
{
	protected $required = true;

	public function __construct($required = true)
	{
		$this->required = $required;
	}
	
	
	public function validate(Validatable $field)
	{
		$value = $field->getValue();
		
		if($value == '')
		{
			if($this->required)
			{
				$field->setError('is verplicht');
				return false;
			}
		}	
		return true;			
	}
	
	public function getError()
	{
		return $this->error;
	}
}